package com.td.module.system.dal.mysql.growth;

import com.td.framework.common.pojo.PageResult;
import com.td.framework.mybatis.core.mapper.BaseMapperX;
import com.td.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.td.module.system.controller.admin.growth.vo.data.GrowthModuleDataExportReqVO;
import com.td.module.system.controller.admin.growth.vo.data.GrowthModuleDataPageReqVO;
import com.td.module.system.dal.dataobject.growth.GrowthModuleDataDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 生长周期 Mapper
 *
 * @author wangxx
 */
@Mapper
public interface GrowthModuleDataMapper extends BaseMapperX<GrowthModuleDataDO> {

    default PageResult<GrowthModuleDataDO> selectPage(GrowthModuleDataPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<GrowthModuleDataDO>()
                .likeIfPresent(GrowthModuleDataDO::getName, reqVO.getName())
                .eqIfPresent(GrowthModuleDataDO::getTimes, reqVO.getTimes())
                .eqIfPresent(GrowthModuleDataDO::getStatus, reqVO.getStatus())
                .eqIfPresent(GrowthModuleDataDO::getGrowthType, reqVO.getGrowthType())
                .eqIfPresent(GrowthModuleDataDO::getModuleAttribution, reqVO.getModuleAttribution())
                .betweenIfPresent(GrowthModuleDataDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(GrowthModuleDataDO::getId));
    }

    default List<GrowthModuleDataDO> selectList(GrowthModuleDataExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<GrowthModuleDataDO>()
                .likeIfPresent(GrowthModuleDataDO::getName, reqVO.getName())
                .eqIfPresent(GrowthModuleDataDO::getTimes, reqVO.getTimes())
                .eqIfPresent(GrowthModuleDataDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(GrowthModuleDataDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(GrowthModuleDataDO::getId));
    }

}
